<?php

/**
 * KTDTrophy form.
 *
 * @package    s-test
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class KTDTrophyForm extends BaseKTDTrophyForm
{
  public function configure()
  {
  }
}
class BackendKTDTrophyForm extends KTDTrophyForm
{
    public function configure(){
        unset($this['created_at'], $this['updated_at']);
        $this->setWidgets(array(
            'name'          =>  new sfWidgetFormInput(array('label'     => 'Nom du trophée')),
            'description'   =>  new sfWidgetFormTextarea(array('label'  => 'Description')),
            'point'         =>  new sfWidgetFormInput(array('label'     => 'Points')),
            'icon'          =>  new sfWidgetFormInputFileEditable(array(
               'label' => 'Icône du trophée',
               'is_image' => true,
               'file_src' => '/uploads/images/trophy/'.$this->getObject()->getIcon(),
               'edit_mode'=> !$this->isNew(),
               'template'  => '%file%<br />%input%<br/>%delete% %delete_label%')),
            'rare_level'    =>  new sfWidgetFormSelect(array('label'=>'Rareté', 'choices'=>KTDTrophy::$LEVELS, 'translate_choices'=>true))
        ));

        $this->validatorSchema['name']  = new sfValidatorString(array('required'=> true));
        $this->validatorSchema['description']   = new sfValidatorString(array('required'=>true));
        $this->validatorSceham['rare_level']    = new sfValidatorChoice(array('choices'=>KTDTrophy::$LEVELS));
        $this->validatorSchema['icon']  = new sfValidatorFile(array(
            'required'   => false,
            'path'       => sfConfig::get('sf_upload_dir').'/images/trophy',
            'mime_types' => 'web_images',
        ));

        $this->widgetSchema->setNameFormat("ktd_trophye[%s]");
    }
}
